

#include <tinyxml/xmlreader.h>


ceXmlReader::ceXmlReader ()
{
}

TiXmlDocument* ceXmlReader::Load (iFile* file)
{
  if (!file)
    {
      printf ("ccXmlReader::Load: file not opened\n"); 
      fflush(stdout);
      return 0;
    }

  file->Seek (SP_End, 0);
  long size = file->Tell ();
  file->Seek (SP_Set, 0);

  char* data = new char[size+1];
  file->Read (data, size);
  data[size] = '\0';


  TiXmlDocument* doc = new TiXmlDocument();
  if (!doc->Parse (data))
    {
      delete [] data;
      delete doc;
      printf ("ccXmlReader: Unable to parse data\n"); 
      fflush(stdout);
      return 0;
    }
  delete [] data;

  return doc;
}

